package org.jarge.fundAssistant.implies;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jarge.fundAssistant.interfaces.IHttpclientService;

public class HttpServiceImpl implements IHttpclientService {

	HttpClient client;
	
	private Log logger = LogFactory.getLog(HttpServiceImpl.class);
	
	public InputStream invoke(String url) {
		client = new HttpClient();
		InputStream response = null;
		HttpMethod method  = new GetMethod(url);
		try {
			client.executeMethod(method);
			response = method.getResponseBodyAsStream();
		} catch (HttpException e) {
			e.printStackTrace();
			logger.error(e);
		} catch (IOException e) {
			e.printStackTrace();
			logger.error(e);
		}
		return response;
	}

}
